from django import forms
from django.db import models
from django.contrib.auth.models import User

# Categories management forms

class AddCategoryForm(forms.Form,):
    """Add category form."""
    
    add_cat_title  = forms.CharField()
    add_cat_parent = forms.CharField()

class DeleteCategoryForm(forms.Form,):
    """Delete category form."""
    
    del_cat_id = forms.CharField()

class EditCategoryForm(forms.Form,):
    """Edit category's title form."""
    
    edt_cat_title = forms.CharField()
    edt_cat_id    = forms.CharField()

# Note management forms

class EditNoteTitleForm(forms.Form,):
    """Edit note's title form."""
    
    edt_note_title = forms.CharField()
    edt_note_id    = forms.CharField()

class EditNoteImportanceForm(forms.Form,):
    """Edit note's importance form."""
    
    edt_note_importance = forms.CharField()

class EditNotePriorityForm(forms.Form,):
    """Edit note's priority form."""
    
    edt_note_priority = forms.CharField()
    edt_note_id = forms.CharField()

class EditNoteDescriptionForm(forms.Form,):
    """Edit note's description form."""
    
    edt_note_description = forms.CharField(widget=forms.Textarea)
    edt_note_id = forms.CharField()

class EditNoteTypeForm(forms.Form,):
    """Edit note's type form."""
    
    edt_note_type = forms.CharField()
    edt_note_id = forms.CharField()

class ArchiveNoteForm(forms.Form,):
    """Archive note form."""
    
    arh_note_id = forms.CharField()

class DeleteNoteForm(forms.Form,):
    """Delete note form."""
    
    del_note_id = forms.CharField()

class AddNoteForm(forms.Form,):
    """Add note form."""
    
    PRIORITY_CHOICES = (
        (u'HT', u'Hot'),
        (u'WR', u'Warm'),
        (u'MD', u'Middle'),
        (u'CH', u'Chilly'),
        (u'CL', u'Cold'),
    )
    
    add_note_title = forms.CharField()
    add_note_description = forms.CharField(widget=forms.Textarea)
    add_note_importance = forms.BooleanField(required=False,widget=forms.CheckboxInput)
    add_note_priority = forms.CharField(widget=forms.RadioSelect(choices=PRIORITY_CHOICES))
    add_note_category = forms.CharField()

class RestoreNoteForm(forms.Form,):
    """Restore note form."""
    
    res_note_id = forms.CharField()

# Add data forms

class AddDataShortForm(forms.Form,):
    """Short add data form."""
    
    add_shr_input = forms.CharField()
    add_note_category = forms.CharField()

# Filter data dorms

class FilterDataShortForm(forms.Form,):
    """Short filter data form."""
    
    filter_shr_input = forms.CharField()

# TEST

class TestForm(forms.Form,):
    test_input = forms.CharField()

# Data models

class Category(models.Model):
    parent   = models.IntegerField (null = True, blank = True)
    title    = models.CharField    (max_length = 200)
    level    = models.IntegerField ()
    position = models.IntegerField ()
    user     = models.ForeignKey   (User)
    
    def __unicode__(self):
        return u'%s %s %s %s' % (self.title, self.parent, self.level, self.position)

class Entity(models.Model):
    TYPE_CHOICES = (
        (u'N', u'Note'),
        (u'T', u'Task'),
        (u'E', u'Event'),
    )
    
    STATE_CHOICES = (
        (u'ACV', u'Active'),
        (u'ARH', u'Archived'),
        (u'LTE', u'Late'),
        (u'LTR', u'Later'),
    )
    
    PRIORITY_CHOICES = (
        (u'HT', u'Hot'),
        (u'WR', u'Warm'),
        (u'MD', u'Middle'),
        (u'CH', u'Chilly'),
        (u'CL', u'Cold'),
    )
    
    COMPLEXITY_CHOICES = (
        (u'C', u'Complex'),
        (u'N', u'Normal'),
        (u'E', u'Easy'),
    )
    
    user     = models.ForeignKey (User)
    category = models.ForeignKey (Category)
    
    type        = models.CharField     (max_length = 1, choices = TYPE_CHOICES)
    title       = models.CharField     (max_length = 1024)
    description = models.TextField     (null = True, blank = True)
    state       = models.CharField     (max_length = 3, choices = STATE_CHOICES)
    create_date = models.DateTimeField (auto_now_add = True)
    from_date   = models.DateTimeField (null = True, blank = True)
    to_date     = models.DateTimeField (null = True, blank = True)
    important   = models.BooleanField  (default = False)
    priority    = models.CharField     (max_length = 2, choices = PRIORITY_CHOICES, default = PRIORITY_CHOICES[2][0])
    complexity  = models.CharField     (max_length = 1, choices = COMPLEXITY_CHOICES, null = True, blank = True, default = None)
    repeater    = models.CharField     (max_length = 40, null = True, blank = True)
    reminder    = models.CharField     (max_length = 40, null = True, blank = True)
    
    def __unicode__(self):
        return u'%s %s %s %s' % (self.type, self.title, self.state, self.create_date)
